const { src, dest } = require('gulp');
var through = require('through2');

function passingCallback() {
    return src('config.js').pipe(through.obj(function (file, encode, cb){
         // 文本内容转为字符串
         var result = file.contents.toString()
         // 添加了一点东西
        //  result += ' \n ' + 'let b = 5'
         result += 'let c = 6'
         // 再次转为Buffer对象，并赋值给文件内容
         file.contents = new Buffer(result)
         // 以下是例行公事
         this.push(file)
        console.log('result', result)
         cb()
    })).pipe(dest('output/'));
}

exports.default = passingCallback;